package com.threeonemeeting.activity;

import java.util.ArrayList;

import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;

import com.threeonemeeting.R;
import com.threeonemeeting.adapter.IconItemListAdapter;
import com.threeonemeeting.listview.CornerListView;
import com.threeonemeeting.model.IconItemInfo;
import com.threeonemeeting.tab.BaseTabActivity;
import com.threeonemeeting.util.MiscUtil;

public class MainMoreActivity extends BaseTabActivity implements
		OnItemClickListener {

	private ArrayList<IconItemInfo> mItems;
	private IconItemListAdapter mAdapter;

	private CornerListView accountList = null;
	private CornerListView aboutList = null;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.ac_more);

		// 管理列表
		accountList = (CornerListView) findViewById(R.id.accountList);
		mItems = new ArrayList<IconItemInfo>();

		IconItemInfo info = new IconItemInfo();
		info.nIconResId = R.drawable.man;
		info.strText = "帐号管理";
		mItems.add(info);

		info = new IconItemInfo();
		info.nIconResId = R.drawable.gear;
		info.strText = "系统设置";
		mItems.add(info);

		info = new IconItemInfo();
		info.nIconResId = R.drawable.save;
		info.strText = "下载管理";
		mItems.add(info);

		info = new IconItemInfo();
		info.nIconResId = R.drawable.rss;
		info.strText = "微博绑定";
		mItems.add(info);

		mAdapter = new IconItemListAdapter(this);
		mAdapter.setIconList(mItems);
		accountList.setAdapter(mAdapter);
		accountList.setOnItemClickListener(this);
		MiscUtil.setListViewHeight(accountList);

		// 关于列表
		aboutList = (CornerListView) findViewById(R.id.aboutList);
		mItems = new ArrayList<IconItemInfo>();

		info = new IconItemInfo();
		info.nIconResId = R.drawable.app_globe;
		info.strText = "最近浏览";
		mItems.add(info);

		info = new IconItemInfo();
		info.nIconResId = R.drawable.comment;
		info.strText = "意见反馈";
		mItems.add(info);

		info = new IconItemInfo();
		info.nIconResId = R.drawable.about;
		info.strText = "关于我们";
		mItems.add(info);

		mAdapter = new IconItemListAdapter(this);
		mAdapter.setIconList(mItems);
		aboutList.setAdapter(mAdapter);
		aboutList.setOnItemClickListener(this);
		MiscUtil.setListViewHeight(aboutList);

	}


	public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
		if (arg0 == accountList) {

			// 账号管理
			if (arg2 == 0) {
				startActivity("AccountListActivity");
			} else if (arg2 == 1) {
				startActivity("SettingActivity");
			}
			// 下载管理
			else if (arg2 == 2) {
				startActivity("DownloadActivity");
			} else if (arg2 == 3) {
				startActivity("WeiboAccountActivity");
			}

		} else if (arg0 == aboutList) {
			if (arg2 == 0) {
				startActivity("RecentMeetingListActivity");
			}

			// 意见反馈项
			else if (arg2 == 1) {
				startActivity("FeedBackActivity");
			} else if (arg2 == 2) {
				startActivity("AboutUsActivity");
			}
		}
	}
}
